﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HouodeFun.TrainCenter.IDAL;
using System.Data.Objects;
using HouodeFun.TrainCenter.Model;

namespace HouodeFun.TrainCenter.DAL
{
    public partial class DbSession : IDbSession  //UnitWork
    {
             

        public int SaveChange()
        {
            IObjectContextFactory tempFactory = new ObjectContextFactory();
            ObjectContext db = tempFactory.GetCurrentThreadInstance();
            return db.SaveChanges();
            
        }

        public int ExcuteSql(string sql, params System.Data.SqlClient.SqlParameter[] paras)
        {
            //using(SqlConnection ......
            IObjectContextFactory tempFactory = new ObjectContextFactory();
            ObjectContext db = tempFactory.GetCurrentThreadInstance();
            return db.ExecuteStoreCommand(sql, paras);
        }
    }


    #region MyRegion
    //public class userserverice()
    //{
    //    public bool deleteuserinfo(userinfo user)
    //    {
    //        IDbSessionFactory fac = new DbSessionFactory();
    //        IDbSession db = fac.GetCurrentDbSession();



    //        new dbsession().userinforepository.deleteentity(user);



    //        new dbsession().userinforepository.addenties(user);

    //        new dbsession().userinforepository.updateentity(user);

    //        savechanger();

    //    }
    //}
    #endregion
   
}
